package hutool;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.io.file.FileWriter;
import org.junit.Test;

import java.io.BufferedReader;
import java.io.IOException;
import java.util.List;

public class IoTest {
   @Test
   public void test1(){

      String filePath = "D:\\temp.txt";
      BufferedReader reader=FileUtil.getReader(filePath,"utf-8");
      String temp;
      try {
         while ((temp = reader.readLine()) != null) {
            System.out.println(temp);
         }
      } catch (IOException ex) {
         IoUtil.close(reader);
      }

      FileReader fileReader = new FileReader(filePath);
      String result = fileReader.readString();
      System.out.println(result);

      FileWriter writer = new FileWriter(filePath);
      //writer.write("test3");
      writer.append("test3");

      FileReader fileReader2 = new FileReader(filePath);
      List<String> stringList = fileReader2.readLines();
      stringList.forEach(s->{
         System.out.println(s);
      });




   }
}
